<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
    <form name="callform" action="radiocall.php" method="POST">
    	Caller name:<input id="caller" name="caller" type="text" />
    	<input type='button' value='Call' onclick='checkWinner(this.form,document.getElementById("caller").value,7)' name=''>
    </form>
</body>
<script type="text/javascript">
	var callNum = 0;
	function checkWinner(form,caller,winningNum) {
		// var callNum;  局部变量掩盖全局变量。
		++callNum;

		if(callNum == winningNum) {
			alert(caller + ",caller number" + callNum +" ...today's winner!")
		}else {
			var callerField = document.getElementById('caller');
			callerField.value = "Next caller";
			callerField.focus();
			callerField.select();
		}
	}
</script>
</html>